using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace ICP_MS;

public class ColorMapCntl : UserControl
{
	private const int IW = 240;

	private const int IH = 162;

	private Image image = null;

	private float zoom = 2f;

	private IContainer components = null;

	private Label lblIsotope;

	private PictureBox pictureImage;

	private Panel panel1;

	public string Caption
	{
		set
		{
			lblIsotope.Text = value;
		}
	}

	public Image Image
	{
		get
		{
			return image;
		}
		set
		{
			image = value;
		}
	}

	public float Zoom
	{
		get
		{
			return zoom;
		}
		set
		{
			zoom = value;
		}
	}

	public ColorMapCntl()
	{
		InitializeComponent();
	}

	private void pictureImage_MouseDown(object sender, MouseEventArgs e)
	{
		if (e.Button == MouseButtons.Right && image != null)
		{
			ContextMenu menu = new ContextMenu();
			menu.MenuItems.Add("复制", delegate
			{
				Clipboard.SetImage(image);
			});
			menu.Show(pictureImage, e.Location);
		}
	}

	private void pictureImage_Paint(object sender, PaintEventArgs e)
	{
		if (image != null)
		{
			Graphics g = e.Graphics;
			int nw = (int)((float)image.Width * zoom);
			int nh = (int)((float)image.Height * zoom);
			g.DrawImage(image, new Rectangle((pictureImage.Width - nw) / 2, (pictureImage.Height - nh) / 2, nw, nh), new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
		}
	}

	public new void Refresh()
	{
		if (image != null)
		{
			int nw = (int)((float)image.Width * zoom);
			int nh = (int)((float)image.Height * zoom);
			if (pictureImage.Width < nw)
			{
				pictureImage.Width = nw;
			}
			else
			{
				pictureImage.Width = 240;
			}
			if (pictureImage.Height < nh)
			{
				pictureImage.Height = nh;
			}
			else
			{
				pictureImage.Height = 162;
			}
			pictureImage.Refresh();
		}
	}

	private void pictureImage_Click(object sender, EventArgs e)
	{
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		this.lblIsotope = new System.Windows.Forms.Label();
		this.pictureImage = new System.Windows.Forms.PictureBox();
		this.panel1 = new System.Windows.Forms.Panel();
		((System.ComponentModel.ISupportInitialize)this.pictureImage).BeginInit();
		this.panel1.SuspendLayout();
		base.SuspendLayout();
		this.lblIsotope.AutoSize = true;
		this.lblIsotope.Font = new System.Drawing.Font("宋体", 9f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
		this.lblIsotope.Location = new System.Drawing.Point(6, 11);
		this.lblIsotope.Name = "lblIsotope";
		this.lblIsotope.Size = new System.Drawing.Size(44, 12);
		this.lblIsotope.TabIndex = 0;
		this.lblIsotope.Text = "。。。";
		this.pictureImage.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
		this.pictureImage.Dock = System.Windows.Forms.DockStyle.Fill;
		this.pictureImage.Location = new System.Drawing.Point(0, 0);
		this.pictureImage.Name = "pictureImage";
		this.pictureImage.Size = new System.Drawing.Size(414, 382);
		this.pictureImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
		this.pictureImage.TabIndex = 1;
		this.pictureImage.TabStop = false;
		this.pictureImage.Click += new System.EventHandler(pictureImage_Click);
		this.pictureImage.Paint += new System.Windows.Forms.PaintEventHandler(pictureImage_Paint);
		this.pictureImage.MouseDown += new System.Windows.Forms.MouseEventHandler(pictureImage_MouseDown);
		this.panel1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.panel1.AutoScroll = true;
		this.panel1.Controls.Add(this.pictureImage);
		this.panel1.Location = new System.Drawing.Point(3, 27);
		this.panel1.Name = "panel1";
		this.panel1.Size = new System.Drawing.Size(414, 382);
		this.panel1.TabIndex = 2;
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.Controls.Add(this.panel1);
		base.Controls.Add(this.lblIsotope);
		base.Name = "ColorMapCntl";
		base.Size = new System.Drawing.Size(421, 414);
		((System.ComponentModel.ISupportInitialize)this.pictureImage).EndInit();
		this.panel1.ResumeLayout(false);
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
